<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">











<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>NPanday - </title>
    <style type="text/css" media="all">
      @import url("./css/maven-base.css");
      @import url("./css/maven-theme.css");
      @import url("./css/site.css");
    </style>
    <link rel="stylesheet" href="./css/print.css" type="text/css" media="print" />
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
      </head>
  <body class="composite">
    <div id="banner">
                    <span id="bannerLeft">
    
            NPanday :: XSD Maven Plugin
    
            </span>
                    <div class="clear">
        <hr/>
      </div>
    </div>
    <div id="breadcrumbs">
          
  

  
    
  
  
    
            <div class="xleft">
        Last Published: 2010-06-23
                      </div>
            <div class="xright">            <a href="http://incubator.apache.org/projects/npanday.html" class="externalLink">Project Site</a>
            |
                <a href="http://incubator.apache.org/npanday" class="externalLink">NPanday</a>
            |
                <a href="http://svn.apache.org/repos/asf/incubator/npanday/" class="externalLink">NPanday SVN</a>
            |
                <a href="http://maven.apache.org/" class="externalLink">Maven</a>
            |
                <a href="http://www.mono-project.com/" class="externalLink">Mono Project</a>
            |
                <a href="http://dotgnu.org/" class="externalLink">DotGNU</a>
            
  

  
    
  
  
    
  </div>
      <div class="clear">
        <hr/>
      </div>
    </div>
    <div id="leftColumn">
      <div id="navcolumn">
           
  

  
    
  
  
    
                   <h5>General Info</h5>
            <ul>
              
    <li class="none">
                    <a href="index.html">About</a>
          </li>
              
    <li class="none">
                    <a href="plugin-info.html">Goals</a>
          </li>
              
    <li class="none">
              <strong>Usage</strong>
        </li>
          </ul>
              <h5>Project Documentation</h5>
            <ul>
              
                
              
      
              
        <li class="collapsed">
                    <a href="project-info.html">Project Information</a>
                </li>
              
                
              
      
            
      
              
        <li class="collapsed">
                    <a href="project-reports.html">Project Reports</a>
                </li>
          </ul>
                                           <a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy">
            <img alt="Built by Maven" src="./images/logos/maven-feather.png"></img>
          </a>
                       
  

  
    
  
  
    
        </div>
    </div>
    <div id="bodyColumn">
      <div id="contentBox">
        <div class="section"><h2>How to Use</h2>
<div class="section"><h3>Generate a class binding/dataset from a schema</h3>
<p>If you already have a schema, then use the xsd goal by adding its execution in the pom.xml file. The xsdFile should point to the xsd.</p>
<div class="source"><pre> &lt;project&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;org.apache.maven.it&lt;/groupId&gt;
  &lt;artifactId&gt;it0006&lt;/artifactId&gt;
  &lt;packaging&gt;library&lt;/packaging&gt;
  &lt;version&gt;1.0.0&lt;/version&gt;
  &lt;name&gt;it0006&lt;/name&gt;
  &lt;build&gt;
    &lt;sourceDirectory&gt;src/main/csharp&lt;/sourceDirectory&gt;
    &lt;testSourceDirectory&gt;src/test/csharp&lt;/testSourceDirectory&gt;
    &lt;plugins&gt;
      &lt;plugin&gt;
        &lt;groupId&gt;npanday.plugin&lt;/groupId&gt;
        &lt;artifactId&gt;maven-compile-plugin&lt;/artifactId&gt;
        &lt;extensions&gt;true&lt;/extensions&gt;
      &lt;/plugin&gt;
      &lt;plugin&gt;
        &lt;groupId&gt;npanday.plugin&lt;/groupId&gt;
        &lt;artifactId&gt;maven-xsd-plugin&lt;/artifactId&gt;
        &lt;executions&gt;
          &lt;execution&gt;
            &lt;goals&gt;
              &lt;goal&gt;xsd&lt;/goal&gt;
            &lt;/goals&gt;
          &lt;/execution&gt;
        &lt;/executions&gt;
        &lt;configuration&gt;
          &lt;xsdFile&gt;StockingHandlers_1_0.xsd&lt;/xsdFile&gt;
        &lt;/configuration&gt;
      &lt;/plugin&gt;
    &lt;/plugins&gt;
  &lt;/build&gt;
&lt;/project&gt;</pre>
</div>
<p>To generate a dataset instead of classes, change the plugin configuation:</p>
<div class="source"><pre> &lt;project&gt;
  [...]
      &lt;plugin&gt;
        &lt;groupId&gt;npanday.plugin&lt;/groupId&gt;
        &lt;artifactId&gt;maven-xsd-plugin&lt;/artifactId&gt;
        &lt;executions&gt;
          &lt;execution&gt;
            &lt;goals&gt;
              &lt;goal&gt;xsd&lt;/goal&gt;
            &lt;/goals&gt;
          &lt;/execution&gt;
        &lt;/executions&gt;
        &lt;configuration&gt;
          &lt;xsdFile&gt;StockingHandlers_1_0.xsd&lt;/xsdFile&gt;
          &lt;generate&gt;dataset&lt;/generate&gt;
        &lt;/configuration&gt;
      &lt;/plugin&gt;
    &lt;/plugins&gt;
  &lt;/build&gt;
&lt;/project&gt;</pre>
</div>
</div>
<div class="section"><h3>Generate a schema from an XML instance and then create a class binding from the generated schema</h3>
<p>You can also generate the schema from a sample XML file prior to generating the bindings. The xmlFiles tag allows you to specify one or more xml files.</p>
<div class="source"><pre>&lt;project&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;org.apache.maven.it&lt;/groupId&gt;
  &lt;artifactId&gt;it0007&lt;/artifactId&gt;
  &lt;packaging&gt;library&lt;/packaging&gt;
  &lt;version&gt;1.0.0&lt;/version&gt;
  &lt;name&gt;it0007&lt;/name&gt;
  &lt;build&gt;
    &lt;sourceDirectory&gt;src/main/csharp&lt;/sourceDirectory&gt;
    &lt;testSourceDirectory&gt;src/test/csharp&lt;/testSourceDirectory&gt;
    &lt;plugins&gt;
      &lt;plugin&gt;
        &lt;groupId&gt;npanday.plugin&lt;/groupId&gt;
        &lt;artifactId&gt;maven-compile-plugin&lt;/artifactId&gt;
        &lt;extensions&gt;true&lt;/extensions&gt;
      &lt;/plugin&gt;
      &lt;plugin&gt;
        &lt;groupId&gt;npanday.plugin&lt;/groupId&gt;
        &lt;artifactId&gt;maven-xsd-plugin&lt;/artifactId&gt;
        &lt;executions&gt;
          &lt;execution&gt;
            &lt;goals&gt;
              &lt;goal&gt;xml&lt;/goal&gt;
              &lt;goal&gt;xsd&lt;/goal&gt;
            &lt;/goals&gt;
          &lt;/execution&gt;
        &lt;/executions&gt;
        &lt;configuration&gt;
          &lt;xmlFiles&gt;
            &lt;xmlFile&gt;${basedir}/registry-config.xml&lt;/xmlFile&gt;
          &lt;/xmlFiles&gt;
          &lt;xsdFile&gt;${project.build.directory}/generated-resources/registry-config.xsd&lt;/xsdFile&gt;
        &lt;/configuration&gt;
      &lt;/plugin&gt;
    &lt;/plugins&gt;
  &lt;/build&gt;
&lt;/project&gt;</pre>
</div>
</div>
</div>

      </div>
    </div>
    <div class="clear">
      <hr/>
    </div>
    <div id="footer">
      <div class="xright">&#169;  
          2010
    
          NPanday
          
  

  
    
  
  
    
  </div>
      <div class="clear">
        <hr/>
      </div>
    </div>
  </body>
</html>
